package com.dofast.bt.mvp.view.activity.main;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.content.Loader;

import com.dofast.bt.R;
import com.dofast.bt.base.BaseApplication;
import com.dofast.bt.base.BaseDate;
import com.dofast.bt.base.BaseMvpActivity;
import com.dofast.bt.mvp.presenter.main.StartPresenter;
import com.dofast.bt.util.PresenterFactory;
import com.dofast.bt.util.PresenterLoder;
import com.dofast.bt.util.SpfUtil;

/**
 * username:Created by hsj on 2016/12/28 0028.
 * class：
 * 类描述：启动界面
 */

public class StartActivity extends BaseMvpActivity<StartPresenter, StartView> implements StartView {

    @Override
    protected int getResourcesId() {
        return R.layout.activity_start;
    }

    @Override
    protected void initView() {
        presenter.initData();
        BaseApplication.getInstance().initDBA();
        if (SpfUtil.getInstance().get("DB") == null) {
            SpfUtil.getInstance().put("DB","1");
            new BaseDate();
        }
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(MainActivity.class, true);
            }
        }, 3000);
    }

    @Override
    protected void addOnClickListener() {

    }

    @Override
    public Loader<StartPresenter> onCreateLoader(int id, Bundle args) {
        return new PresenterLoder<>(this, new PresenterFactory<StartPresenter>() {
            @Override
            public StartPresenter create() {
                return new StartPresenter();
            }
        });
    }

    @Override
    public void initTitle() {

    }

    @Override
    public void gotoActivity(Class<?> tClass, boolean isFinish) {
        startActivity(tClass, isFinish);
    }
}
